﻿#pragma once
#include <QString>
#include <QCoreApplication>
#define CONFIG_INI_PATH qApp->applicationDirPath() + "/Config.ini"
#define CONFIG_INI_PRODUCTS_PATH qApp->applicationDirPath() + "/config/ProductsConfig.ini"
#define CONFIG_LOG_PATH qApp->applicationDirPath() + "/log/config.log"
#define LOGIN_URL_INI_KEY "/Request/LOGINURL"
#define PROJECT_URL_INI_KEY "/Request/PROJECTURL"

#define GLOBAL_HOST_URL "/Global/HostUrl"
#define GLOBAL_YT_LOGIN_TOKEN "/Global/YtToken"
#define GLOBAL_MES_LOGIN_TOKEN "/Global/MesToken"
#define GLOBAL_CURRENT_PRODUCT "/Global/CurrentProduct"

#define USERNAME_INI_KEY "/BasicAuth/UserName"
#define PASSWORD_INI_KEY "/BasicAuth/PassWord"

#define CAFILE_INI_KEY "/SSL/CAFilePath"
#define CERTFILE_INI_KEY "/SSL/CertFilePath"
#define CERTFILETYPE_INI_KEY "/SSL/CertFileType"
#define KEYFILE_INI_KEY "/SSL/KeyFilePath"
#define KEYFILETYPE_INI_KEY "/SSL/KeyFileType"
#define KEYPASSWORD_INI_KEY "/SSL/KeyPassWord"

#define MES_LOGIN_URL_INI_KEY		"/Request/MESLOGINURL"
#define MES_USERNAME_INI_KEY		"/BasicAuth/MesUserName"
#define MES_PASSWORD_INI_KEY		"/BasicAuth/MesPassWord"
#define MES_LOGIN_FORM_INI_KEY		"/LoginForm/MesIsSavePassword"

#define LOGIN_FORM_INI_KEY "/LoginForm/IsSavePassword"

#define STR_LOGIN_TOKEN "Login_Token"
#define STR_SERIAL_NUMBER "Serial_Number"
#define STR_CURRENT_PRODUCT "Current_Product"
#define STR_CURRENT_AI_URL "Current_Ai_Url"
#define STR_AI_SERVICE_STATUS "Ai_Service_Status"
#define STR_DET_SCENE_NAME "det"
#define STR_DET_CLS_SCENE_NAME "det_cls"
#define STR_OCR_SCENE_NAME "ocr"
#define STR_TAG_PASTE_SCENE_NAME "tag_paste"
#define STR_DET_DET_SCENE_NAME "det_det"
#define STR_DET_DET_CLS_SCENE_NAME "det_det_cls"
#define STR_DET_OCR_SCENE_NAME "det_ocr"
#define STR_DET_SEG_SCENE_NAME "det_seg"
//segmentation
#define STR_SEG_SCENE_NAME "seg" 

#define STR_TASK_TYPE_WITHREG "WithReg"
#define STR_TASK_TYPE_WITHOUT_REG "WithoutReg"
#define STR_CODE_TYPE_JPG "jpg"

#define REQ_HEADER_KEY_UUID "uuid"
#define REQ_HEADER_KEY_IP "ip"
#define REQ_HEADER_KEY_VERSION_SOFTWARE "vision-software"
#define REQ_HEADER_KEY_SCENE_NAME "scene-name"
#define REQ_HEADER_VALUE_VERSION_SOFTWARE "opt"

#define TOKEN_Index_POS 0
#define SERIAL_NUMBER_Index_POS 1
#define CURRENT_PRODUCT_Index_POS 2

#define HanleParamOutQuick(i, val)		\
if (m_paraOutput[i].enabled())\
{\
	m_paraOutput[i].setValid(true);\
	m_paraOutput[i].setValue(val);\
}\
else\
{\
	m_paraOutput[i].setValid(false);\
}

#define SetOprOutputVariablesQuick(i, val)		\
if (m_paraOutput[i].enabled())\
{\
	m_paraOutput[i].setValid(true);\
	m_paraOutput[i].setValue(val);\
}\
else\
{\
	m_paraOutput[i].setValid(false);\
}


/**
* @class          SSLParamer
* @brief          SSL所需的参数
*/
typedef struct _SSLParamer
{
	QString certFileType;
	QString keyFileType;
	QString CAFilePath;
	QString certFilePath;
	QString keyFilePath;
	QString keyPassWord;
} SSLParamer;

typedef struct _BasicAuth
{
	QString UserName;
	QString PassWord;
} BasicAuth;

void readBasicAuth(BasicAuth &basicAuth);
void saveBasicAuth(BasicAuth basicAuth);
void readSSLParams(SSLParamer &sslParams);
void saveSSLParams(SSLParamer sslParams);
QString readGlobalIniConfig(QString configFilePath, QString key);
QString readGlobalIniConfig(QString key);
void writeGlobalIniConfig(QString configFilePath, QString key, QString value);
void writeGlobalIniConfig(QString key, QString value);